package com.hspedu.transformation;


import java.io.*;

/**
 * @Author Stringzhua
 * @Date 2024/3/17 13:33
 * description:OutputStreamWriter的使用演示
 * 将FileOutputStream 字节流,转成字符串 OutputStreamWriter
 * 指定处理的编码 gbk/utf-8/utf8
 */
public class OutputStreamWriter_ {
    public static void main(String[] args) throws IOException {
        String filePath = "e:\\qiyeke\\filecontroller\\b.txt";
        String charSet = "utf-8";
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(filePath), charSet);
        osw.write("hi,爪爪吃蒸饺");
        osw.close();
        System.out.println("按照 " + charSet + "文件保存成功");
    }
}
